# 数字炸弹
import random
BLUE = "\033[34m"
RED = "\033[31m"
RESET = "\033[0m"
YELLOW = "\033[33m"
MAGENTA = "\033[35m"
player1_score = 0
player2_score = 0
current_player = 1
print(f"{BLUE}欢迎来到数字炸弹游戏，游戏双方轮流输入数字，范围也会随其越变越小，最终猜到爆炸数字的玩家将会-1分，同时另一个玩家+1分，\n一方分数达到所设定时，一局游戏结束，炸弹数字范围最初在1-100之间（包含1和100），请正确按提示输入范围，接下来游戏正式开始！！！！\n温馨提示（小BUG）：输入数字时如果输入非数字类字符或不输入直接回车会造成游戏直接崩溃，感谢理解{RESET}\n")
print(f"{BLUE}内容更新：更新了角色系统：刘邦，诸葛亮；新增分数叠加以加快游戏进度;新增狂暴模式，更刺激，更快速{RESET}")
num = random.randint(1, 100)
while True:
    win = int(input(f"{RED}请输入达成获胜条件的分数：\n{RESET}"))
    model = int(input("请选择游戏模式：\n1.普通模式  2.狂暴模式\n"))
    if model == 2:
        num = random.randint(1, 10)
    player1 = int(input(f"{RED}请玩家一选择自己的角色：\n{BLUE}1.刘邦：每次积分结算胜利时，对方积分额外-1\n2.诸葛亮：每次积分结算胜利时，自身积分额外+1\n{RESET}"))
    player2 = int(input(f"{RED}请玩家二选择自己的角色：\n{BLUE}1.刘邦：每次积分结算胜利时，对方积分额外-1\n2.诸葛亮：每次积分结算胜利时，自身积分额外+1\n{RESET}"))
    begin = 0
    end = 101
    game = 0
    i = 0
    if model == 2:
        end = 11
    print(f"{RED}当前得分 - 玩家一：%i，玩家二：%i{RESET}" % (player1_score, player2_score))
    while True:
        if current_player == 1:
            a = int(input(f"{YELLOW}玩家一，输入你想猜的数字：\n{RESET}"))
        else:
            a = int(input(f"{YELLOW}玩家二，输入你想猜的数字：\n{RESET}"))
        if a <= begin or a >= end:
            print(f"{RED}输入范围不正确，请重新输入{RESET}")
            print("数字范围在%i~%i之间" % (begin, end))
        elif num < a:
            print("恭喜你暂时安全，炸弹数字范围在%i~%i之间（不包括%i和%i）" % (begin, a, begin, a))
            end = a
            current_player = 3 - current_player
        elif num > a:
            print("恭喜你暂时安全，炸弹数字范围在%i~%i之间（不包括%i和%i）" % (a, end, a, end))
            begin = a
            current_player = 3 - current_player
        else:
            if current_player == 1:
                print(f"{RED}boom！boom！boom！玩家一爆炸了，数字炸弹为%i{RESET}" % num)
                if player2 == 1 :
                    print(f"{BLUE}玩家二刘邦触发技能{RESET}")
                    player1_score -=i/10+1
                    player2_score +=i/10+1
                    player1_score -= 1
                else:
                    print(f"{BLUE}玩家二诸葛亮触发技能{RESET}")
                    player1_score -=i/10+1
                    player2_score +=i/10+1
                    player2_score += 1
                game += 1
                if game %10 == 0 :
                    print(f"{RED}积分急速！！！！！！！！！！！！{RESET}")
                    i += 10
                print(f"{RED}当前第%i局得分 - 玩家一：%i，玩家二：%i{RESET}" % (game,player1_score, player2_score))
                num = random.randint(1, 100)
                if model == 2:
                    num = random.randint(1, 10)
                begin = 0
                end = 101
                if model == 2:
                    end = 11
            else:
                print(f"{RED}boom！boom！boom！玩家二爆炸了，数字炸弹为%i{RESET}" % num)
                if player1 == 1 :
                    print(f"{BLUE}玩家一刘邦触发技能{RESET}")
                    player2_score -=i/10+1
                    player1_score +=i/10+1
                    player2_score -= 1
                else :
                    print(f"{BLUE}玩家一诸葛亮触发技能{RESET}")
                    player2_score -=i/10+1
                    player1_score +=i/10+1
                    player1_score += 1
                game += 1
                if game %10 == 0 :
                    print(f"{RED}积分急速！！！！！！！！！！！！{RESET}")
                    i += 10
                print(f"{RED}当前第%i局得分 - 玩家一：%i，玩家二：%i{RESET}" % (game,player1_score, player2_score))
                num = random.randint(1, 100)
                if model == 2:
                    num = random.randint(1, 10)
                begin = 0
                end = 101
                if model == 2:
                    end = 11
        if player1_score >= win or player2_score >= win:
            break
    if player1_score > player2_score:
        print(f"{MAGENTA}恭喜玩家一获胜{RESET}")
    else:
        print(f"{MAGENTA}恭喜玩家二获胜{RESET}")
    restart = input(f"{RED}还要再玩一局吗？Y/N\n{RESET}")
    if restart == "N" or restart == "n":
        break
    else:
        print(f"{BLUE}游戏继续嗨！{RESET}")
        player1_score = 0
        player2_score = 0
print(f"{BLUE}无不散之宴席，欢迎下次再玩！！！{RESET}")



